#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const int N=5*1e3+10;


void solve()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    vector<vector<int>> dp(n+1,vector<int>(k+1));
    if(n<3)
    {
        cout<<0<<endl;
        return;
    }
    int ret=0;
    s=' '+s;
    for(int i=3;i<=n;i++)
    {
        int cost=(s[i]!='o')+(s[i-1]!='v')+(s[i-2]!='o');
    
        for(int j=0;j<=k;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=cost)
            {
                dp[i][j]=max(dp[i][j],dp[i-3][j-cost]+1);
                ret=max(ret,dp[i][j]);
            }
            
        }
    }
    cout<<ret<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {    
        solve();
    }
    return 0;
}
